package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysRoomMapper;
import com.ruoyi.system.domain.SysRoom;
import com.ruoyi.system.service.ISysRoomService;
import com.ruoyi.common.core.text.Convert;

/**
 * 班级Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@Service
public class SysRoomServiceImpl implements ISysRoomService 
{
    @Autowired
    private SysRoomMapper sysRoomMapper;

    /**
     * 查询班级
     * 
     * @param roomId 班级主键
     * @return 班级
     */
    @Override
    public SysRoom selectSysRoomByRoomId(Long roomId)
    {
        return sysRoomMapper.selectSysRoomByRoomId(roomId);
    }

    /**
     * 查询班老师级
     *
     * @param userId 老师主键
     * @return 班级
     */
    @Override
    public SysRoom selectSysRoomByUserId(Long userId)
    {
        return sysRoomMapper.selectSysRoomByUserId(userId);
    }

    /**
     * 查询分校
     *
     * @param deptId 分校主键
     * @return 班级
     */
    @Override
    public List<SysRoom> selectSysRoomByDeptId(Long deptId)
    {
        return sysRoomMapper.selectSysRoomByDeptId(deptId);
    }

    /**
     * 查询班级列表
     * 
     * @param sysRoom 班级
     * @return 班级
     */
    @DataScope(deptAlias = "d", userAlias = "u")
    @Override
    public List<SysRoom> selectSysRoomList(SysRoom sysRoom)
    {
        return sysRoomMapper.selectSysRoomList(sysRoom);
    }

    /**
     * 新增班级
     * 
     * @param sysRoom 班级
     * @return 结果
     */
    @Override
    public int insertSysRoom(SysRoom sysRoom)
    {
        sysRoom.setCreateTime(DateUtils.getNowDate());
        return sysRoomMapper.insertSysRoom(sysRoom);
    }

    /**
     * 修改班级
     * 
     * @param sysRoom 班级
     * @return 结果
     */
    @Override
    public int updateSysRoom(SysRoom sysRoom)
    {
        sysRoom.setUpdateTime(DateUtils.getNowDate());
        return sysRoomMapper.updateSysRoom(sysRoom);
    }

    /**
     * 批量删除班级
     * 
     * @param roomIds 需要删除的班级主键
     * @return 结果
     */
    @Override
    public int deleteSysRoomByRoomIds(String roomIds)
    {
        return sysRoomMapper.deleteSysRoomByRoomIds(Convert.toStrArray(roomIds));
    }

    /**
     * 删除班级信息
     * 
     * @param roomId 班级主键
     * @return 结果
     */
    @Override
    public int deleteSysRoomByRoomId(Long roomId)
    {
        return sysRoomMapper.deleteSysRoomByRoomId(roomId);
    }
}
